<template>
  <div style="">
    <Header :left="true" leftText="返回" title="问题产品处置申请"> </Header>
    <div class="textScroll">
      <!-- 文字信息 -->
      <van-row style="margin-top: 10px">
        <van-col>
          <van-image width="40" height="30" style="margin-left: -10px" src="assets/block.png" />
        </van-col>
        <van-col class="message" style="margin-top: 5px">问题产品处置申请信息</van-col>
      </van-row>
      <div class="divMessage">
        <van-form :style="autoHeight">
          <van-row style="margin-left: 10px; margin-top: 10px">
            <van-col span="5"><b>工厂:</b></van-col>
            <van-col span="19">{{ item.FactoryID }}</van-col>
          </van-row>
          <van-row style="margin-left: 10px; margin-top: 10px">
            <van-col span="5"><b>生产线:</b></van-col>
            <van-col span="19">{{ item.PLineID }}</van-col>
          </van-row>
          <van-row style="margin-left: 10px; margin-top: 10px">
            <van-col span="5"><b>订单号:</b></van-col>
            <van-col span="19">{{ item.POrderID }}</van-col>
          </van-row>
          <van-row style="margin-left: 10px; margin-top: 10px">
            <van-col span="5"><b>产品名称:</b></van-col>
            <van-col span="19">{{ item.MaterialName }}</van-col>
          </van-row>
          <van-row style="margin-left: 10px; margin-top: 10px">
            <van-col span="5"><b>产品代码:</b></van-col>
            <van-col span="19">{{ item.MaterialID }}</van-col>
          </van-row>
          <van-row style="margin-left: 10px; margin-top: 10px">
            <van-col span="5"><b>生产日期:</b></van-col>
            <van-col span="19">{{ item.ProductionDate }}</van-col>
          </van-row>
          <van-row style="margin-left: 10px; margin-top: 10px">
            <van-col span="5"><b>生产班次:</b></van-col>
            <van-col span="19">{{ showShiftIDName(item.PShiftID) }}</van-col>
          </van-row>
          <van-row style="margin-left: 10px; margin-top: 10px">
            <van-col span="5"><b>生产班组:</b></van-col>
            <van-col span="19">{{ showTeamIDName(item.TeamID) }}</van-col>
          </van-row>

          <van-row style="margin-left: 10px; margin-top: 10px">
            <van-col span="5"><b>问题批次号:</b></van-col>
            <van-col span="19">{{ item.BatchID }}</van-col>
          </van-row>
          <van-row style="margin-left: 10px; margin-top: 10px">
            <van-col span="5"><b>待处理数量:</b></van-col>
            <van-col span="19">{{ item.DeFectAmount }} &nbsp; {{ item.MUnitID }}</van-col>
          </van-row>
          <van-row style="margin-left: 10px; margin-top: 10px">
            <van-col span="5"><b>缺陷类型:</b></van-col>
            <van-col span="19">
              <van-field readonly style="font-weight: bold;border:1px solid #ccc!important;width: 95%;margin: 0 auto;"
                v-model="text" class="formstyle" rows="4" autosize label="" type="textarea" maxlength="150" placeholder=""
                show-word-limit />
            </van-col>
          </van-row>
          <van-row style="margin-left: 10px; margin-top: 10px">
            <van-col span="5"><b>缺陷描述:</b></van-col>
            <van-col span="19">{{ item.DefectMemo }}</van-col>
          </van-row>
          <van-row style="margin-left: 10px; margin-top: 10px">
            <van-col span="5"><b>发起人:</b> </van-col>
            <van-col span="19">
              {{ item.Creator }} &nbsp; {{ item.CreateDatetime }}
            </van-col>
          </van-row>
          <!-- <van-row style="margin-left: 10px; margin-top: 10px">
            <van-col span="5"><b>建议处置方式:</b></van-col>
            <van-col span="19">{{ showDealType(item.AdviceDealType) }}</van-col>
          </van-row>
          <van-row style="margin-left: 10px; margin-top: 10px">
            <van-col span="5"><b>建议处置意见:</b></van-col>
            <van-col span="19">{{ item.AdviceMemo }}</van-col>
          </van-row> -->
          <van-row style="margin-left: 10px; margin-top: 10px" v-if="item.FixedDealType != '暂无'">
            <van-col span="5"><b>最终处置方法:</b></van-col>
            <van-col span="19">{{ showDealType(item.FixedDealType) }}</van-col>
          </van-row>
          <van-row style="margin-left: 10px; margin-top: 10px" v-if="item.FixedDealType == '暂无'">
            <van-col span="5"><b>最终处置方法:</b></van-col>
            <van-col span="19">{{ item.FixedDealType }}</van-col>
          </van-row>
        </van-form>

        <!-- <div style="margin: 16px"
          v-if="item.AppearanceCheckRecord != 0 && item.AppearanceCheckRecord != '' && item.AppearanceCheckRecord != null">
          <van-button color="" round block type="info" @click="getRecord(item.AppearanceCheckRecord)"
            style="">查看外观检验不合格记录</van-button>
        </div>
        <div style="margin: 16px">
          <van-button color="#23C6C8" round block type="info" @click="checkSYS">查看实验室检验不合格项</van-button>
        </div>
        <div style="margin: 16px">
          <van-button color="#1AB394" round block type="info" @click="openQA">打开质量辅助决策界面</van-button>
        </div>
        <div style="margin: 16px">
          <van-button color="#1AB394" round block type="info" @click="CheckTM">查看实验室复测记录</van-button>
        </div> -->

        <van-row gutter="20">
        <van-col span="12">
          <div style="margin: 16px">
            <van-button color="#008792" round block type="info" @click="getRecord(form.AppearanceCheckRecord1)"
              style="">查看外观检验不合格记录</van-button>
          </div>
        </van-col>
        <van-col span="12">
          <div style="margin: 16px">
            <van-button color="#33a3dc" round block type="info" @click="checkSYS">查看实验室检验不合格项</van-button>
          </div>
        </van-col>
      </van-row>

      <van-row gutter="20">
        <van-col span="12">
          <div style="margin: 16px">
            <van-button color="#1AB394" round block type="info" @click="openQA">打开质量辅助决策界面</van-button>
          </div>
        </van-col>
        <van-col span="12">
          <div style="margin: 16px">
            <van-button color="#005831" round block type="info" @click="CheckTM">查看实验室复测记录</van-button>
          </div>
        </van-col>
      </van-row>
      </div>

      <!-- 品管领班 -->
      <NoticeBar color="#1989fa" background="#ecf9ff" style="margin-top: 5px; font-size: 15px; font-weight: bold"
        left-icon="description">品管领班审核意见</NoticeBar>
      <!-- <van-row style="margin-left: 10px; margin-top: 10px">
        <van-col span="5"><b>是否同意:</b></van-col>
        <van-col span="19">
          <span v-if="item.QCLeaderAgree == '1' ? true : false">同意处置意见</span>
          <span v-else>不同意处置意见</span>
        </van-col>
      </van-row> -->
      <van-row style="margin-left: 10px; margin-top: 10px">
        <van-col span="5"><b>处理方式:</b></van-col>
        <van-col span="19">{{
          showDealType(item.QCLeaderAdviceDealType)
        }}</van-col>
      </van-row>
      <van-row style="margin-left: 10px; margin-top: 10px">
        <van-col span="5"><b>处置建议:</b></van-col>
        <van-col span="19">{{ item.QCLeaderMemo }}</van-col>
      </van-row>

      <!-- 质量制程主任/跟班制程主管 -->
      <div v-if="item.TeamLeaderChecked">
        <NoticeBar color="#1989fa" background="#ecf9ff" style="margin-top: 5px; font-size: 15px; font-weight: bold"
          left-icon="description">品管主任审核意见</NoticeBar>
        <!-- <van-row style="margin-left: 10px; margin-top: 10px">
          <van-col span="5"><b>是否同意:</b></van-col>
          <van-col span="19">
            <span v-if="item.TeamLeaderAgree == '1' ? true : false">同意处置意见</span>
            <span v-else>不同意处置意见</span>
          </van-col>
        </van-row> -->
        <van-row style="margin-left: 10px; margin-top: 10px">
          <van-col span="5"><b>处理方式:</b></van-col>
          <van-col span="19">{{
            showDealType(item.TeamLeaderAdviceDealType)
          }}</van-col>
        </van-row>
        <van-row style="margin-left: 10px; margin-top: 10px">
          <van-col span="5"><b>处置建议:</b></van-col>
          <van-col span="19">{{ item.TeamLeaderMemo }}</van-col>
        </van-row>
      </div>

      <!-- 生产现场主管 -->
      <div v-if="item.OnSiteLeaderChecked">
        <NoticeBar color="#1989fa" background="#ecf9ff" style="margin-top: 5px; font-size: 15px; font-weight: bold"
          left-icon="description">生产现场主管审核意见</NoticeBar>
        <van-row style="margin-left: 10px; margin-top: 10px">
          <van-row style="margin-left: 10px; margin-top: 10px">
            <van-col span="5"><b>处置建议:</b></van-col>
            <van-col span="19">{{ item.OnSiteLeaderMemo }}</van-col>
          </van-row>
        </van-row>
      </div>

      <!-- <div v-if="item.PrdManagerChecked && item.FromTeamLeader && item.QCMangerUserID !== '' && item.PrdSpecialPurchase">
        <NoticeBar color="#1989fa" background="#ecf9ff" style="margin-top: 5px; font-size: 15px; font-weight: bold"
          left-icon="description">生产部门负责人审核意见</NoticeBar>
        <van-row style="margin-left: 10px; margin-top: 10px">
          <van-col span="5"><b>处置建议:</b></van-col>
          <van-col span="19">生产部门负责人:{{ item.PrdMangerUserID }}不同意质量制程主任/跟班制程主管审核意见,并发起特采流程！</van-col>
        </van-row>
      </div> -->

      <!-- 质量负责人 -->
      <div v-if="item.QCManagerChecked">
        <NoticeBar color="#1989fa" background="#ecf9ff" style="margin-top: 5px; font-size: 15px; font-weight: bold"
          left-icon="description">质量负责人审核意见</NoticeBar>
        <!-- <van-row style="margin-left: 10px; margin-top: 10px">
          <van-col span="5"><b>是否放行:</b></van-col>
          <van-col span="19">
            <span v-if="item.QCManagerAgree == '1' ? true : false">同意放行</span>
            <span v-else>不同意放行</span>
          </van-col>
        </van-row> -->
        <van-row style="margin-left: 10px; margin-top: 10px">
          <van-col span="5"><b>处置方式:</b></van-col>
          <van-col span="19">{{
            showDealType(item.QCManagerAdviceDealType)
          }}</van-col>
        </van-row>
        <van-row style="margin-left: 10px; margin-top: 10px">
          <van-col span="5"><b>处置建议:</b></van-col>
          <van-col span="19">{{ item.QCMangerMemo }}</van-col>
        </van-row>
      </div>

      <!-- 生产部门负责人 -->
      <div v-if="item.PrdManagerChecked">
        <NoticeBar color="#1989fa" background="#ecf9ff" style="margin-top: 5px; font-size: 15px; font-weight: bold"
          left-icon="description">生产部门负责人审核意见</NoticeBar>
        <van-row style="margin-left: 10px; margin-top: 10px">
          <van-col span="5"><b>处置建议:</b></van-col>
          <van-col span="19">{{ item.PrdMangerMemo }}</van-col>
        </van-row>
      </div>

      <!-- 利润点负责人 -->
      <div v-if="item.FactoryManagerChecked">
        <NoticeBar color="#1989fa" background="#ecf9ff" style="margin-top: 5px; font-size: 15px; font-weight: bold"
          left-icon="description">利润点负责人审核意见</NoticeBar>
        <van-row style="margin-left: 10px; margin-top: 10px">
          <van-col span="5"><b>处置方式:</b></van-col>
          <van-col span="19">{{
            showDealType(item.FactoryManagerDealType)
          }}</van-col>
        </van-row>
        <van-row style="margin-left: 10px; margin-top: 10px">
          <van-col span="5"><b>处置建议:</b></van-col>
          <van-col span="19">{{ item.FactoryMangerMemo }}</van-col>
        </van-row>
      </div>

      <!--<NoticeBar
        color="#1989fa"
        background="#ecf9ff"
        style="margin-top: 5px; font-size: 15px; font-weight: bold"
        left-icon="description"
        >审核流程</NoticeBar
      >
      <van-steps direction="vertical" :active="active" >
        <van-step  v-if = "item.QCLeaderChecked == '1' ">
        <h3>品管领班</h3>
          <div v-if = "item.QCLeaderAgree =='0' && item.QCLeaderChecked == '1' ">
            <p>{{item.QCLeaderMemo}}</p>
            <p>处理方式: {{item.QCLeaderAdviceDealType}}</p> 
          </div>
          <div v-else-if = "item.QCLeaderAgree =='1' && item.QCLeaderChecked == '1' ">
            <p>同意处置意见！</p>
            <p>建议处置方式: {{showDealType(item.QCLeaderAdviceDealType)}}</p>          
            <p>{{item.QCLeaderCheckDatetime}}</p>
          </div>           
        </van-step>
        <van-step v-if = "item.TeamLeaderChecked == '1' ">
          <h3>质量制程主任/跟班制程主管</h3>
          <div v-if = "item.TeamLeaderAgree =='0' && item.TeamLeaderChecked == '1' ">
            <p>{{item.TeamLeaderMemo}}</p>
          </div>
          <div v-else-if = "item.TeamLeaderAgree =='1' && item.TeamLeaderChecked == '1' ">
            <p>同意处置意见！</p>          
            <p>{{item.QCLeaderCheckDatetime}}</p>
          </div>    
        </van-step>
        <div v-if="item.FromTeamLeader && item.PrdManagerAgree">
     
          <van-step>
            <h3>生产部门负责人</h3>
            <p>{{item.PrdMangerMemo}}</p>
            <p>处理方式: {{item.PrdManagerAdviceDealType}}</p> 
          </van-step>
          <van-step>
            <h3>归档</h3>       
            <P>最终处置方式: {{item.FixedDealType}}</P>
            <P>处置方式最终决定人:{{item.FixedMan}}</P>
            <p>{{item.FixedDatetime}}</p>
          </van-step>
        </div>
        <div v-if="item.FromTeamLeader && !item.PrdManagerAgree">
       
          <van-step>
            <h3>生产部门负责人一审</h3>
            <p>{{item.PrdMangerMemo}}</p>
            <p>处理方式: {{item.PrdManagerAdviceDealType}}</p> 
          </van-step>
          <van-step v-if = "item.QCManagerChecked == '1' ">
            <h3>质量负责人</h3>            
            <p>{{item.QCMangerMemo}}</p>
            <p>处理方式: {{item.QCManagerAdviceDealType}}</p> 
          </van-step>
          <van-step>
            <h3>归档</h3>       
            <P>最终处置方式: {{item.FixedDealType}}</P>
            <P>处置方式最终决定人:{{item.FixedMan}}</P>
            <p>{{item.FixedDatetime}}</p>
          </van-step>
        </div>
        <van-step v-if = "item.QCManagerChecked == '1' ">
          <h3>质量负责人</h3>
          <div v-if = "item.QCManagerAgree =='0' && item.QCManagerChecked == '1' ">
            <p>{{item.QCMangerMemo}}</p>
            <p>处理方式: {{item.QCManagerAdviceDealType}}</p> 
          </div>
          <div v-else-if = "item.QCManagerAgree =='1' && item.QCManagerChecked == '1' ">
            <p>同意处置意见！</p>
            <p>处理方式: {{item.QCManagerAdviceDealType}}</p>          
            <p>{{item.QCManagerCheckDatetime}}</p>
          </div>    
        </van-step>
        <van-step>
          <h3>生产部门负责人</h3>
          <div v-if = "item.PrdManagerAgree =='0' && item.PrdManagerChecked == '1' ">
            <p>{{item.PrdMangerMemo}}</p>
            <p>处理方式: {{item.PrdManagerAdviceDealType}}</p> 
          </div>
          <div v-else-if = "item.PrdManagerAgree =='1' && item.PrdManagerChecked == '1' ">
            <p>同意处置意见！</p>
            <p>处理方式: {{item.PrdManagerAdviceDealType}}</p>          
            <p>{{item.PrdManagerCheckDatetime}}</p>
          </div>    
        </van-step>
        <van-step v-if = " item.FactoryManagerChecked == '1' ">
          <h3>利润点负责人</h3>          
            <p>{{item.FactoryMangerMemo}}</p>
            <p>处理方式: {{showDealType(item.FactoryManagerDealType)}}</p>   
        </van-step>
        <van-step  v-if="item.PlaceOnFile">
          <h3>归档</h3>
          <div v-if="item.FixedDealType !== null || item.FixedDealType !== '' ">
          <P>最终处置方式: {{item.FixedDealType}}</P>
          <P>处置方式最终决定人:{{item.FixedMan}}</P>
          <p>{{item.FixedDatetime}}</p>
          </div>  
        </van-step>
      </van-steps>-->
    </div>
  </div>
</template>

<script>
import {
  Col,
  Row,
  Form,
  Cell,
  Icon,
  Field,
  NumberKeyboard,
  Image as VanImage,
  Picker,
  popup,
  SubmitBar,
  Button,
  Loading,
  Overlay,
  Dialog,
  Toast,
  NoticeBar,
  Tag,
  DatetimePicker,
  ImagePreview,
  CellGroup,
  Uploader,
  Cascader,
  Calendar,
  RadioGroup,
  Radio,
  Divider,
  Stepper,
  AddressList,
  Checkbox,
  CheckboxGroup,
  Step,
  Steps,
} from "vant";

import "vue-easytable/libs/themes-base/index.css";
import { VTable } from "vue-easytable";
import { _httpClient } from "@/libs/apisie";
import { getToken, getBaseApiFrefix } from "@/libs/auth";
import Header from "@/components/header.vue";
import { storage } from "@/libs/utils";

Vue.use(Form);
Vue.use(Field);
Vue.use(Overlay);
Vue.use(Loading);
Vue.use(Picker);
Vue.use(popup);
Vue.use(SubmitBar);
Vue.use(VanImage);
Vue.use(DatetimePicker);
Vue.use(Cascader);
Vue.use(Calendar);
Vue.use(Cell);
Vue.use(RadioGroup);
Vue.use(Radio);
Vue.use(Divider);
Vue.use(Stepper);
Vue.use(Button);
Vue.use(AddressList);
Vue.use(Checkbox);
Vue.use(CheckboxGroup);
Vue.use(Col);
Vue.use(Row);
Vue.use(Step);
Vue.use(Steps);

export default {
  name: "ckCheckedItem",
  components: {
    Form,
    Row,
    Col,
    Button,
    Header,
    Form,
    Cell,
    Icon,
    Field,
    NumberKeyboard,
    Dialog,
    Toast,
    NoticeBar,
    Row,
    Tag,
    popup,
    DatetimePicker,
    ImagePreview,
    CellGroup,
    Uploader,
    Col,
    Calendar,
    Cascader,
    Picker,
    RadioGroup,
    Radio,
    Divider,
    Stepper,
    VTable,
    AddressList,
    Checkbox,
    CheckboxGroup,
  },
  data() {
    return {
      active: 0,
      minDate: new Date(2022, 12, 1),
      nowDate: null,
      text: "",
      form: {
        QCLeaderAdviceDealType: "",
        QCLeaderMemo: "",
        Id: "",
        //班组
        valueteamid: "",
        //订单号码
        pOrderID: "",
        //产品代码
        materialid: "",
        //产品名称
        materialname: "",
        //生产日期
        ProductionDate: "",
        //班次开始日期
        planworkdatetime: "",
        //班次
        pShiftID: "",
        //检验类型
        CheckTypeID: "",
        //包装条码
        BarCode: "",
        //检验备注
        Memo: "",
        ProductionAmount: "",
        //抽样计划1G
        SamplePlan1G: "",
        //抽样计划1Re
        SamplePlan1Re: "",
        //抽检值1
        SamplePlan1Value: "",
        //抽样计划2G
        SamplePlan2G: "",
        //抽样计划2AC
        SamplePlan2AC: "",
        //抽样计划2AQL
        SamplePlan2AQL: "",
        //抽检值2
        SamplePlan2Value: "",
        //生产批次
        BatchID: "",
        //缺陷原因
        QProblemID: "",
        //管理责任
        ManageReasonID: "",
        //生产车间
        WorkshopID: "",
        //领班是否同意
        QCLeaderAgree: "",
      },
      user: [],
      QCLeaderAgreeValue: "",
      plineID: "",
      ManageReasonName: "",
      time: "",
      FactoryID: "",
      valuepShiftName: "",
      CheckTypeName: "",
      QProblemName: "",
      valueteamid: "",
      BeginTime: "",
      WorkPlanDatetimeFrom: "",
      columnsteamId: [],
      showPickerteamid: false,
      showPickerpShiftID: false,
      showPickerDealType: false,
      valueemployid: "",
      columnsshift: [],
      columnsType: [],
      columnsDealType: [],
      columnsManageReason: [
        { ManageReasonID: "0", ManageReasonName: "无异常" },
      ],
      columnsQProblem: [{ QProblemID: "0", QProblemName: "无异常" }],
      showPickerType: false,
      showPickerManageReason: false,
      showPickerQProblem: false,
      item: {},
      valuepDealTypeName: "",
    };
  },
  destroyed() {
    clearInterval(this.nowtimer);
    this.nowDate = null;
  },
  created: function () {
    //console.log("Hello");
    this.user = JSON.parse(storage.get("user"));
    this.user.userId = this.user.userName;
    this.item = api.pageParam.item;
    this.text = this.item.QProblemID + this.item.ManageReasonID + this.item.FunctionProblemID
    this.nowDate = new Date().toLocaleString();
    //this.initPage();
    //获取班组信息
    this.getteam();
    //获取班次信息
    this.getshift();
    //获取检验类型
    //this.getCheckType();
    //管理责任数据
    // this.getManageReasonID();
    this.getQualityProblems();
    //获取建议处置方式
    this.getDealType();
  },
  mounted() {
    this.checkActive(this.item);
  },
  methods: {
    getRecord(id) {


      api.openWin({
        name: 'qCcheckReview',
        url: './quality-qCcheckReview.html',
        pageParam: {
          id: id
        }
      });

    },
    async CheckTM() {
      let id = this.item.LaboratoryCheckRecord;
      let CheckItem = this.item.CheckItem;
      let CheckBatch = this.item.CheckBatch;
      //alert(CheckBatch);
      if (CheckBatch =="全项检验") {
        CheckBatch = "问题产品复核检验-全项"
      }
      else {
        CheckBatch = "问题产品复核检验-过程"
      }

      if (id == "" || id == null || id == undefined) {
        Toast.clear()
        Toast.fail("当前没有维护实验室复测记录，无法获取复测记录！")
        return
      }

      api.openWin({
        name: 'viewlaboratorytest1',
        url: './equipmentsj-viewlaboratorytest1.html',
        pageParam: {
          id: this.item.LaboratoryCheckRecord,
          CheckBatch: CheckBatch,
          CheckItem: this.item.CheckItem
        }
      });
    },
    async checkSYS() {
      let id = this.item.LaboratoryCheckRecord;
      let CheckItem = this.item.CheckItem;
      let CheckBatch = this.item.CheckBatch;

      if (id == "" || id == null || id == undefined) {
        Toast.clear()
        Toast.fail("当前没有维护实验室检验记录，无法获取不合格记录！")
        return
      }

      api.openWin({
        name: 'viewlaboratorytest',
        url: './equipmentsj-viewlaboratorytest.html',
        pageParam: {
          id: this.item.LaboratoryCheckRecord,
          CheckBatch: this.item.CheckBatch,
          CheckItem: this.item.CheckItem
        }
      });
    },
    openQA() {
      let _this = this
      // alert(_this.form.POrderID)
      api.openWin({
        name: 'qAssistance',
        url: './qAssistance-qualityAssistance.html',
        pageParam: {
          POrderID: _this.item.POrderID,
          PlineID: _this.item.PLineID
        }
      });


    },
    checkActive(item) {
      //先判断生产现场主管是否审核且同意
      if (item.TeamLeaderChecked) {
        if (item.TeamLeaderAgree) {
          //若同意，active=5，直接归档
          this.active = 3;
        }
      } else {
        return;
      }
      //判断质量负责人是否审核
      if (item.QCManagerChecked) {
        //if(item.QCManagerAgree){
        //若同意，active=5，直接归档
        this.active = 3;
        //}
        //若不同意，判断生产部门负责人状态
      } else {
        //等待质量负责人审核
        this.active = 1;
        return;
      }
      //判断生产部门负责人是否审核
      //if(item.PrdManagerChecked){
      //if(item.PrdManagerAgree){
      //若同意，active=5，直接归档
      //this.active = 5;
      //}
      //若不同意，判断利润点负责人状态
      //}else{
      //未审核
      //this.active = 2;
      //return;
      //}
      //判断利润点负责人是否同意
      //if(item.FactoryManagerChecked){
      //if(item.FactoryManagerAgree){
      //若同意，active=5，直接归档
      //this.active = 5;
      //}else{
      //若不同意，active=5，也直接归档
      //this.active = 5;
      //}
      //}else{
      //this.active = 3;
      //return;
      //}
    },
    onConfirmDealType(value, index) {
      this.valuepDealTypeName = this.columnsDealType[index].DealTypeName;
      this.form.QCLeaderAdviceDealType = this.columnsDealType[index].DealTypeID;
      this.showPickerDealType = false;
    },
    showTeamIDName(teamID) {
      var teamName = teamID;
      this.columnsteamId.forEach((item) => {
        if (item.teamId === teamID) {
          teamName = item.teamName;
        }
      });
      return teamName;
    },
    showShiftIDName(pShiftID) {
      var pShiftName;
      this.columnsshift.forEach((item) => {
        if (item.pShiftID === pShiftID) {
          pShiftName = item.pshiftname;
        }
      });
      return pShiftName;
    },
    showManageReason(ManageReason) {
      if (ManageReason == "" || null == ManageReason) {
        ManageReason = "0";
      }
      this.columnsManageReason.forEach((item) => {
        if (item.ManageReasonID == ManageReason) {
          this.ManageReasonName = item.ManageReasonName;
        }
      });
    },
    showQProblemID(QProblemID) {
      var QProblemName;
      this.columnsQProblem.forEach((item) => {
        if (item.QProblemID === QProblemID) {
          QProblemName = item.QProblemName;
        }
      });
      return QProblemName;
    },
    showDealType(type) {
      var DealTypeName;
      this.columnsDealType.forEach((item) => {
        if (item.DealTypeID === type) {
          DealTypeName = item.DealTypeName;
        }
      });
      return DealTypeName;
    },
    changeAgreeValue() {
      //如果合格 隐藏页面 直接提交
      if (this.QCLeaderAgreeValue == "1") {
        this.form.QCLeaderAgree = true;
        this.valuepDealTypeName = this.showDealType(this.item.AdviceDealType);
        this.form.QCLeaderAdviceDealType = this.item.AdviceDealType;
        this.form.QCLeaderMemo =
          "品管领班:" + this.user.employeeName + "同意处置意见!";
      } else {
        //若不同意
        this.form.QCLeaderAgree = false;
        this.valuepDealTypeName = "";
        this.form.QCLeaderAdviceDealType = "";
        this.form.QCLeaderMemo =
          "品管领班:" + this.user.employeeName + "不同意处置意见!";
      }
    },
    //获取班组信息
    async getteam() {
      let _this = this;
      try {
        let res = await _httpClient.get(
          _httpClient.getApiPrefix() +
          "/Team/GetList?FactoryID=" +
          _this.item.FactoryID
        );
        if (res.HttpCode === "200") {
          let teamMap = res.Data.map((item) => ({
            teamId: item.TeamID,
            teamName: item.TeamName,
          }));
          _this.columnsteamId = teamMap;
        }
      } catch (e) {
        Toast.fail(JSON.stringify(e));
      }
    },
    //获取班次信息
    async getshift() {
      let _this = this;
      try {
        let res = await _httpClient.get(
          _httpClient.getApiPrefix() +
          "/ProductionShift/GetList?FactoryID=" +
          _this.item.FactoryID
        );
        if (res.HttpCode === "200") {
          for (let index = 0; index < res.Data.length; index++) {
            if (res.Data[index].Actived == false) {
              delete res.Data[index];
            }
          }
          let shiftMap = res.Data.map((item) => ({
            pshiftname: item.PShiftName + " " + item.BeginTime,
            pShiftID: item.PShiftID,
            BeginTime: item.BeginTime,
          }));
          _this.columnsshift = shiftMap;
        }
      } catch (e) {
        Toast.fail(JSON.stringify(e));
      }
    },
    //获取缺陷原因
    async getQualityProblems() {
      let _this = this;
      try {
        let res = await _httpClient.get(
          _httpClient.getApiPrefix() + "/QualityProblems/GetList"
        );

        if (res.HttpCode === "200") {
          let temp = res.Data.map((item) => ({
            QProblemID: item.QProblemID,
            QProblemName: item.QProblemName,
          }));
          temp.forEach((item) => {
            _this.columnsQProblem.push(item);
          });
        }
      } catch (e) {
        Toast.fail(JSON.stringify(e));
      }
    },
    //获取建议处置方式
    async getDealType() {
      let _this = this;
      try {
        let res = await _httpClient.get(
          _httpClient.getApiPrefix() + "/QualityDealType/GetList"
        );
        if (res.HttpCode === "200") {
          let temp = res.Data.map((item) => ({
            DealTypeID: item.DealTypeID,
            DealTypeName: item.DealTypeName,
          }));
          temp.forEach((item) => {
            _this.columnsDealType.push(item);
          });
        }
      } catch (e) {
        Toast.fail(JSON.stringify(e));
      }
    },
    //获取管理责任
    async getManageReasonID() {
      let _this = this;
      try {
        let res = await _httpClient.get(
          _httpClient.getApiPrefix() + "/QualityManageReason/GetList"
        );
        if (res.HttpCode === "200") {
          let temp = res.Data.map((item) => ({
            ManageReasonID: item.ManageReasonID,
            ManageReasonName: item.ManageReasonName,
          }));
          temp.forEach((item) => {
            _this.columnsManageReason.push(item);
          });
        }
      } catch (e) {
        Toast.fail(JSON.stringify(e));
      }
    },
    async getCheckType() {
      let _this = this;
      try {
        let res = await _httpClient.get(
          _httpClient.getApiPrefix() + "/QualityCheckType/GetList"
        );
        if (res.HttpCode === "200") {
          let shiftMap = res.Data.map((item) => ({
            CheckTypeName: item.CheckTypeName,
            CheckTypeID: item.CheckTypeID,
          }));
          _this.columnsType = shiftMap;
        }
      } catch (e) {
        Toast.fail(JSON.stringify(e));
      }
    },
    itemClear() {
      this.form.Id = "";
      this.form.valueteamid = "";
      this.form.pShiftID = "";
      this.form.pOrderID = "";
      this.form.materialid = "";
      this.form.materialname = "";
      this.form.planworkdatetime = "";
      this.form.ProductionDate = "";
      this.form.CheckTypeID = "";
      //包装条码
      this.form.BarCode = "";
      //检验备注
      this.form.Memo = "";
      this.form.ProductionAmount = "";
      //抽样数量
      //抽样计划1G
      this.form.SamplePlan1G = "";
      //抽样计划1Re
      this.form.SamplePlan1Re = "";
      //抽检值1
      this.form.SamplePlan1Value = "";
      //抽样计划2G
      this.form.SamplePlan2G = "";
      //抽样计划2AC
      this.form.SamplePlan2AC = "";
      //抽样计划2AQL
      this.form.SamplePlan2AQL = "";
      //抽检值2
      this.form.SamplePlan2Value = "";
      //生产批次
      this.form.BatchID = "";
      //缺陷原因
      this.form.QProblemID = "";
      //管理责任
      this.form.ManageReasonID = "";
      //生产车间
      this.form.WorkshopID = "";
      //检验是否合格
      this.form.QualityOk = "";
      //客户名称
      this.form.CustomerName = "";
      this.QCLeaderAgreeValue = "";
      this.plineID = "";
      this.ManageReasonName = "";
      this.time = "";
      this.FactoryID = "";
      this.valuepShiftName = "";
      this.CheckTypeName = "";
      this.QProblemName = "";
      this.valueteamid = "";
      this.BeginTime = "";
      this.WorkPlanDatetimeFrom = "";
      this.columnsteamId = [];
      this.showPickerteamid = false;
      this.showPickerpShiftID = false;
      this.valueemployid = "";
      this.columnsshift = [];
      this.columnsType = [];
      this.columnsManageReason = [
        { ManageReasonID: "0", ManageReasonName: "无异常" },
      ];
      this.columnsQProblem = [{ QProblemID: "0", QProblemName: "无异常" }];
      this.showPickerType = false;
      this.showPickerManageReason = false;
      this.showPickerQProblem = false;
    },
    onConfirmManageReason(value, index) {
      this.form.ManageReasonID = this.columnsManageReason[index].ManageReasonID;
      this.ManageReasonName = this.columnsManageReason[index].ManageReasonName;
      this.showPickerManageReason = false;
      if (this.form.QProblemID == "0" && this.form.ManageReasonID == "0") {
        this.QCLeaderAgreeValue = "1";
        this.form.QualityOk = true;
      } else {
        this.QCLeaderAgreeValue = "0";
        this.form.QualityOk = false;
      }
    },
    //确认提交表单
    async submitsure() {
      let _this = this;
      //时间+8还是有问题 直接传字符串也行
      //var workPlanDatetimeFrom = new Date(this.form.planworkdatetime);
      Toast.loading({
        mask: true,
        forbidClick: true,
        duration: 0,
        message: "请稍等...",
      });
      var manageReasonID = _this.form.ManageReasonID;
      var qProblemID = _this.form.QProblemID;
      if (manageReasonID == "0") {
        manageReasonID = "";
      }
      if (qProblemID == "0") {
        qProblemID = "";
      }
      try {
        let res = await _httpClient.post(
          _httpClient.getApiPrefix() + "/QualityAppearanceCheck/SaveEntity",
          {
            body: {
              //生产日期
              productionDate: _this.form.ProductionDate,
              workshopID: _this.form.WorkshopID,
              pLineID: _this.plineID,
              checkTypeID: _this.form.CheckTypeID,
              qualityOk: _this.form.QualityOk,
              qProblemID: qProblemID,
              barCode: _this.form.BarCode,
              memo: _this.form.Memo,
              pOrderID: _this.form.pOrderID,
              materialID: _this.form.materialid,
              materialName: _this.form.materialname,
              customerName: _this.form.CustomerName,
              productionAmount: _this.form.ProductionAmount,
              samplePlan1G: _this.form.SamplePlan1G,
              samplePlan1Re: _this.form.SamplePlan1Re,
              samplePlan1Value: _this.form.SamplePlan1Value,
              samplePlan2G: _this.form.SamplePlan2G,
              samplePlan2AC: _this.form.SamplePlan2AC,
              samplePlan2AQL: _this.form.SamplePlan2AQL,
              samplePlan2Value: _this.form.SamplePlan2Value,
              batchID: _this.form.BatchID,
              teamID: _this.form.valueteamid,
              pShiftID: _this.form.pShiftID,
              factoryID: _this.FactoryID,
              //班次开始日期
              workPlanDatetimeFrom: _this.form.planworkdatetime,
              manageReasonID: manageReasonID,
              deleteFlag: _this.form.deleteFlag,
              Modifytor: _this.user.userId,
              id: _this.form.Id,
            },
          }
        );
        if (res.Message != null) {

          Toast.clear();
          Toast.fail("保存失败,请核对信息！");
        } else {
          //打卡成功
          Toast.clear();
          Toast.success("保存成功！");
        }
      } catch (e) {
        Toast.fail(JSON.stringify(e));
      }
    },
  },
};
</script>

<style>
body {
  background-color: white;
}

.table-title-class {
  background-color: #304156;
  color: #fff;
}

.wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

.buttongroup {
  float: right;
  margin-right: 10px;
  margin-top: 10px;
  margin-bottom: 20px;
}

.container.dwo {
  display: flex;
  justify-content: center;
  align-items: center;
}

.buttonLeft {
  position: fixed;
  bottom: 8px;
  float: left;
  width: 49%;
}

.formstyle {
  margin-top: 8px;
  font-size: 15px;
  font-weight: bold;
  display: flex;
  align-items: center;
}

.radioteam {
  display: flex;
  align-items: center;
  padding-left: 13px;
  margin-top: 10px;
  margin-left: 34px;
  margin-bottom: 10px;
}

.buttonRight {
  position: fixed;
  bottom: 8px;
  float: right;
  left: 51%;
  width: 49%;
  background-color: #f22028;
  border-color: #f22028;
}

.textScroll {
  display: inline-block;
  position: fixed;
  top: 5rem;
  bottom: 0rem;
  overflow: scroll;
  right: 0;
  width: 100%;
  z-index: 1;
}

.message {
  font-size: 15px;
  margin-top: 5px;
  margin-left: -10px;
  font-weight: bold;
}

.mg5 {
  margin-right: 5px;
}

.tag_margin {
  margin: 2px 5px;
}

.card_under {
  height: 100%;
  width: 100%;
  margin: auto;
  background: #ffffff;
  border-radius: 25px;
  box-shadow: 0 0px 0px rgba(0, 0, 0, 0.3);
}

.card_icon {
  text-align: center;
  /* position: absolute; */
  height: 8rem;
  width: 80%;
  margin: 12% 10%;
  background: rgba(35, 180, 237, 1);
  border-radius: 25px;
  box-shadow: 0 10px 50px rgba(0, 0, 0, 0.3);
}

.text {
  font-size: 18px;
  color: #4e4a67;
  margin: 8px auto auto 20px;
  line-height: 1.5rem;
  text-align: justify;
  font-weight: 600;
}

.text_small {
  font-size: 16px;
  color: red;
  margin: 8px auto auto 20px;
  line-height: 1.5rem;
  text-align: justify;
  font-weight: 700;
}

.text_scan {
  font-size: 16px;
  color: #4e4a67;
  margin: auto auto auto 20px;
  line-height: 1.5em;
  text-align: justify;
}

.divStyle {
  margin-left: 3px;
  margin-right: 3px;
}

.divMessage {
  margin-top: 0px;
  border: solid #dcdcdc;
  margin-left: 5px;
  margin-right: 15px;
  border-top-width: 4px;
  border-left-width: 4px;
  border-right-width: 1px;
  border-bottom-width: 1px;
}</style>
